package com.yowasa.xiuxian.engine.travel.adventure;


import com.google.common.collect.Sets;
import com.yowasa.xiuxian.engine.travel.AdventureInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.MapEnum;
import com.yowasa.xiuxian.entity.enums.RefreshType;
import com.yowasa.xiuxian.service.helper.ResourceHelper;
import com.yowasa.xiuxian.service.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 仙人传承奇遇 九星连珠刷新
 * 获取偷天诀
 */
@Component
public class XianRenChuanCheng implements AdventureInterface {
    @Autowired
    private ResourceHelper resourceHelper;
    @Autowired
    private UserHelper userHelper;

    @Override
    public Set<MapEnum> limitMaps() {
        //仙人洞only
        return Sets.newHashSet(MapEnum.JUE_YUN_JIAN);
    }
    //todo 秘境玩法应该更多样
    @Override
    public String exec(UserBO user) {
        String msg = "你在此地发现了仙人的传承石碑,上面记载者[偷天诀]神通的传承";
        if (!resourceHelper.checkHaveResource(user.getGuildId(), this.getClass().getName(), RefreshType.JIU_XING)) {
            msg += "但是传承已经被他人接收";
        } else {
            if (user.getUserConfig().getKnownSpecialEffect().contains("偷天诀")) {
                msg += ",但是你已经掌握了此神通";
            } else {
                msg += ",你接受了传承,获取了[偷天诀]的修习之法";
                user.getUserConfig().getKnownSpecialEffect().add("偷天诀");
                resourceHelper.useResource(user.getGuildId(), this.getClass().getName());
            }
        }
        userHelper.lockUser(user,30,user.getName()+"探索秘境中");
        return msg;
    }

    @Override
    public boolean isConflict() {
        return true;
    }

    public int weight() {
        return 4;
    }
}
